<!-- 登录页面 -->
<template>
  <div class="login_page">
    <!-- 验证码组件 -->
    <verificationCode @getCode="getCode"></verificationCode>

    <el-button type="primary" @click="doLogin">{{
      $t("login.title")
    }}</el-button>
  </div>
</template>

<script setup>
//引入动态验证码组件
import verificationCode from "../../components/verification_code/index.vue";
// 导入pinia对象
import Store from "@/store/index";
import { useRouter } from "vue-router";
//导入所有的路由
import { allAsyncRouter } from "@/route/allAsyncRouter";
import { filterAsyncRoterArr, setDefaultRoute } from "@/utils/RouteUtil";

const store = Store();

//route对象
const router = useRouter();

//
const getCode = (val) => {
  console.log("传递的验证码是:", val);
};

//登录操作
const doLogin = () => {
  //根据用户角色过滤路由
  let roleType = 1;
  let fliterRoutes = filterAsyncRoterArr(roleType, allAsyncRouter);

  //配置默认路由
  setDefaultRoute(fliterRoutes);

  // console.log("过滤好的路由是:", fliterRoutes);

  store.useMenu.setMenuList(fliterRoutes);
  router.push({ path: "/order/order-list" });
};
</script>
<style lang="scss" scoped>
.login_page {
}
</style>
